# -*- coding: cp932 -*-
'''
Created on 2012/05/09

@author: yanagi
'''

class Support(object):
    '''
    classdocs
    '''


    def __init__(self, name):
        '''
        Constructor
        '''
        self.name = name

    def setNext(self, next):
        self.next = next
        return next

    def support(self, trouble):
        if self.resolve(trouble):
            self.done(trouble)
        elif self.next != None:
            self.next.support(trouble)
        else:
            self.fail(trouble)

    def toString(self):
        return "[" + self.name + "]"

    def resolve(self, trouble):
        pass

    def done(self, trouble):
        print trouble + " is resolved by "  + self + "."

    def fail(self, trouble):
        print trouble + " cannot be resolved."